| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkGraphics::Resource Class Referenceabstract

Base class for a resource in the component. More...

Inheritance diagram for nkGraphics::Resource:

## Public Member Functions
virtual | ~Resource ()
bool | isReadyForRendering () const
bool | isUnloaded () const
RESOURCE_LOAD_STATE | getLoadState () const
nkMemory::StringView | getPath () const
RESOURCE_TYPE | getTypeName () const
nkMemory::StringView | getName () const
System * | getSystem () const
bool | getHidden () const
bool | getGpuUploadCanBeDeferred () const
virtual void | setPath (nkMemory::StringView value)
void | setName (nkMemory::StringView value)
void | setHidden (bool value)
void | setGpuUploadCanBeDeferred (bool value)
virtual bool | load ()=0
virtual void | unload ()=0

## Detailed Description

Base class for a resource in the component.

## Constructor & Destructor Documentation

## ◆ ~Resource()

virtual nkGraphics::Resource::~Resource | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ isReadyForRendering()

bool nkGraphics::Resource::isReadyForRendering | ( |  | ) | const

Returns
  Whether the resource is ready for rendering (true) or not (false). A resource is ready if it is loaded and all memory is populated.

## ◆ isUnloaded()

bool nkGraphics::Resource::isUnloaded | ( |  | ) | const

Returns
  Whether the resource is unloaded (true) or not (false).

## ◆ getLoadState()

RESOURCE_LOAD_STATE nkGraphics::Resource::getLoadState | ( |  | ) | const

The current load state of the resource.

## ◆ getPath()

nkMemory::StringView nkGraphics::Resource::getPath | ( |  | ) | const

Returns
  The resource path, relative to the working directory. See nkResources::ResourceManager for path naming conventions.

## ◆ getTypeName()

RESOURCE_TYPE nkGraphics::Resource::getTypeName | ( |  | ) | const

Returns
  The resource type name.

## ◆ getName()

nkMemory::StringView nkGraphics::Resource::getName | ( |  | ) | const

Returns
  The resource name.

## ◆ getSystem()

System* nkGraphics::Resource::getSystem | ( |  | ) | const

Returns
  The system the resource lives in.

## ◆ getHidden()

bool nkGraphics::Resource::getHidden | ( |  | ) | const

Returns
  Whether the resource is hidden (true) or not (false). A hidden resource is not processed for saving when exporting a resource set.

## ◆ getGpuUploadCanBeDeferred()

bool nkGraphics::Resource::getGpuUploadCanBeDeferred | ( |  | ) | const

Returns
  Whether the resource GPU load can safely be deferred (true) or not (false).

## ◆ setPath()

virtual void nkGraphics::Resource::setPath | ( | nkMemory::StringView | value | ) |
| virtual

Sets the resource's path, relative to the working directory. See nkResources::ResourceManager for path naming conventions.

Parameters

  value | The path to use.

Reimplemented in nkGraphics::Texture.

## ◆ setName()

void nkGraphics::Resource::setName | ( | nkMemory::StringView | value | ) |

Sets the resource name.

Parameters

  value | The resource name to use.

## ◆ setHidden()

void nkGraphics::Resource::setHidden | ( | bool | value | ) |

Sets whether the resource is hidden or not. Hidden resource do not contribute to resource set save requests. By default, this is set to false.

Parameters

  value | Whether the resource should be hidden (true) or not (false).

## ◆ setGpuUploadCanBeDeferred()

void nkGraphics::Resource::setGpuUploadCanBeDeferred | ( | bool | value | ) |

Sets whether the resource's loading is safe to be deferred before rendering a scene or not.

This behavior is relevant to the Dx12 rendering API if chosen. By design, Gles and Dx11 require all loading resources to be ready before rendering, at the expense of potential hiccups if it is necessary to wait for them. The Dx12 renderer has been designed with a "no-hiccup" strategy, meaning that loading resources that are not ready yet won't prevent rendering. Instead, they will be gracefully handled in the background. A mesh won't be painted for instance, and only appear once GPU is ready to render it on next frames. If this flag is set to false, then the Dx12 renderer will have the same behavior as the Gles and Dx11 renderers and wait for resources.

By default, this is set to true.

Parameters

  value | Whether the resource GPU load can safely be deferred (true) or not (false).

## ◆ load()

virtual bool nkGraphics::Resource::load | ( |  | ) |
| pure virtual

Loading function. A resource goes into different states through its lifetime.

- Created. It is awaiting configuration by external code. At this point, the resource can already be used everywhere, but it will have default values, often resulting in a no-op.
- Loading. The configuration has been made and the load function has been called. For some resources, this status is bypassed.
- Loaded. The resource has been loaded and all memory has been populated. At this point, the resource should operate as described.

It is possible to loop through these states during the resource lifetime, if needed.

Returns
  Whether the loading went well (true) or not (false).

Implemented in nkGraphics::Program, nkGraphics::Mesh, and nkGraphics::Shader.

## ◆ unload()

virtual void nkGraphics::Resource::unload | ( |  | ) |
| pure virtual

Unloads the resource, and places it back into its created state. Frees all internal memory used to initialize it.

Implemented in nkGraphics::Program, and nkGraphics::Shader.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/Resources/Resource.h